package modell;
import java.awt.Component;
import java.io.File;

import com.sun.j3d.utils.geometry.Cylinder;
import com.sun.j3d.utils.geometry.Primitive;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.image.TextureLoader;

import javax.media.j3d.Alpha;
import javax.media.j3d.AmbientLight;
import javax.media.j3d.Appearance;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.ImageComponent2D;
import javax.media.j3d.Material;
import javax.media.j3d.PointLight;
import javax.media.j3d.RotationInterpolator;
import javax.media.j3d.Texture;
import javax.media.j3d.Texture2D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;

public class Canonball extends BranchGroup{

	
	// Part 1 ist auskommmentiert, da irgendwo noch ein Fehler vorliegt..o_o
	
	
	/*
	 Appearance createTwistAppearance(){

	        Appearance twistAppear = new Appearance();

	        String filename = "goldi.jpg";
	        System.out.println("attempt to load texture from file: "+filename);
	        TextureLoader loader = new TextureLoader(filename, this);
	        ImageComponent2D image = loader.getImage();

	        if(image == null) {
	            System.out.println("load failed for texture: "+filename);
	        }

	        Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA,
	                                      image.getWidth(), image.getHeight());
	        texture.setImage(0, image);
	        texture.setEnable(true);

	        texture.setMagFilter(Texture.BASE_LEVEL_LINEAR);
	        texture.setMinFilter(Texture.BASE_LEVEL_LINEAR);

	        twistAppear.setTexture(texture);

	        return twistAppear;
	    }
	   */
	    public void createSceneGraph() {

	        BranchGroup contentRoot = new BranchGroup();

	        TransformGroup objSpin = new TransformGroup();
	        objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
	        contentRoot.addChild(objSpin);

	    
	        Transform3D scale = new Transform3D();
	  
	        scale.set(0.5);
	       
	        objSpin.setTransform(scale);
	        
	        Appearance ap = new /*createTwist*/ Appearance();
	        objSpin.addChild(new Sphere(.4f, Primitive.GENERATE_TEXTURE_COORDS, ap));
	        
	        Alpha rotationAlpha = new Alpha(-1, 400);
	  
	        RotationInterpolator rotator =
	                 new RotationInterpolator(rotationAlpha, objSpin);
	 
	        BoundingSphere bounds = new BoundingSphere();
	        rotator.setSchedulingBounds(bounds);
	        objSpin.addChild(rotator);

	   
	   
	        contentRoot.compile();
	    	    }

	} 

	 
	  
 
